package com.newx.test.file.controller;

import com.newx.file.config.NewxFileConfig;
import com.newx.file.enums.FileEngineTypeEnum;
import com.newx.file.service.NewxFileService;
import com.newx.test.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

/**
 * @author yxl
 * @date 2024/7/23 0023 14:09
 */
@RestController
@RequestMapping("/file")
public class FileController {

    @Autowired
    private NewxFileService newxFileService;
//    @Autowired
//    private NewxFileConfig newxFileConfig;

    @PostMapping("/upload")
    public String uploadFile() {
        return "success";
    }

    /**
     * 本地文件上传，返回文件Url
     *
     * @author xuyuxiang
     * @date 2023/11/23 14:01
     **/
    @PostMapping("/uploadLocal/{engine}")
    public R uploadLocalReturnUrl(@PathVariable String engine,
                                  @RequestPart(value = "file",required = true) MultipartFile file) {
        Object local = newxFileService.fileApiRoute(engine, file);
        return R.ok().data(local);
    }

}
